/*
 * This file (AkBlur.java) is protected by the GNU GPL licence (v2). 
 * Please read the license.txt attached for further informations. 
 * 
 */

package alkwarel.filters;

import processing.core.PConstants;
import alkwarel.objects.AkArtspace;
import alkwarel.objects.AkFilter;
import artx.parameters.AxFloatParameter;
import artx.utils.AxLog;

/**
 * Blurs the artspace.
 * @author Xavier Gouchet
 *
 */
public class AkBlur extends AkFilter {

	/**
	 * Standard Consrtuctor.
	 */
	public AkBlur() {
		super(0, "Blur", new String[]{"blur radius","float"});
	}

	/**
	 * @see alkwarel.objects.AkFilter#Apply(alkwarel.objects.AkArtspace)
	 */
	public boolean Apply(AkArtspace a) {
		AxFloatParameter blurRad = null;
		try{
			blurRad = (AxFloatParameter) a.GetParameterManager().GetElement("blur radius");
		}catch (ClassCastException e){
			AxLog.Debug("AkBlur::Apply =>> can't cast parameter \"blur radius\" to float");
		}
		if (blurRad!= null){
			a.filter(PConstants.BLUR, blurRad.GetValue());
		}else{
			a.filter(PConstants.BLUR, 1);
		}
		return true;
	}

}
